<template>
  <el-dialog :title="title" :width="width"
             :visible.sync="isShowVisible"
             center :close-on-click-modal="false"
             :before-close="() => $emit('close')">
    <el-card>
      <div style="white-space: pre; overflow-x: auto">{{xmlCode}}</div>
    </el-card>
    <div slot="footer" class="dialog-footer">
      <el-button @click="$emit('close')">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import ModelManageApi from '@/api/workFlow/ModelManageApi'
  import vkbeautify from 'vkbeautify'
  export default {
    name: 'previewModel',
    props: {
      width: {
        type: String,
        default: '60vw'
      },
      modelId: {
        type: String,
      },
    },
    data() {
      return {
        title: '预览',
        isShowVisible: true,
        xmlCode: '',
      }
    },
    created() {
      let http = new ModelManageApi()
      http.preView({ modelId: this.modelId }).then(res => {
        this.xmlCode = res.data
        vkbeautify.xml(this.xmlCode)
      }).catch(err => {
      })
    },
  }
</script>

<style scoped lang="scss">

</style>
